package com.swak.utils;

import com.swak.utils.time.DateTimes;

/**
 * 有效期校验
 * 
 * @author 618lf
 */
public class ExpireUtils {

	/**
	 * 处于有效期
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return
	 */
	public static boolean dayIndate(java.time.LocalDateTime beginDate, java.time.LocalDateTime endDate) {
		java.time.LocalDateTime day = DateTimes.getNowStart();
		if (beginDate != null && endDate != null) {
			return !beginDate.isAfter(day) && !endDate.isBefore(day);
		} else if (beginDate != null) {
			return !beginDate.isAfter(day);
		}
		return !endDate.isBefore(day);
	}

	/**
	 * 处于有效期
	 * 
	 * @param beginDate
	 * @param endDate
	 * @return
	 */
	public static boolean timeIndate(java.time.LocalDateTime beginDate, java.time.LocalDateTime endDate) {
		java.time.LocalDateTime time = DateTimes.now();
		if (beginDate != null && endDate != null) {
			return beginDate.isBefore(time) && endDate.isAfter(time);
		} else if (beginDate != null) {
			return beginDate.isBefore(time);
		}
		return endDate.isAfter(time);
	}
}